package com.talkative.plan.config;

import io.swagger.annotations.Api;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author : best
 * @date : 2022/10/3
 */
@Configuration //配置类
@EnableSwagger2 //启用Swagger
public class SwaggerConfig {
    /**
     * 构建文档的基本信息
     */
    public ApiInfo createApi(){
        return new ApiInfoBuilder().
                title("多嘴计划项目接口文档")
                .description("仿下厨房APP")
                .contact(new Contact("杨硕、赵消、李会宾、李博、左立伟、刘豆豆","http://120.48.141.45/",""))
                .version("1.0.0").build();
    }

    /**
     * 就是ioc创建实例 修饰方法 方法必须返回对象
     */
    @Bean //等同于<bean> 配合@Configuration 会把方法的返回值存储到IOC容器
    public Docket createDocket(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(createApi())
                .select().apis(RequestHandlerSelectors.
                        withClassAnnotation(Api.class)).build();
    }
}
